package com.fjrcloud.controller;

import com.fjrcloud.entity.Formalities;
import com.fjrcloud.entity.LandStandard;
import com.fjrcloud.entity.ResponseBean;
import com.fjrcloud.entity.ResponseFactory;
import com.fjrcloud.exception.BusinessException;
import com.fjrcloud.service.LandStandardService;
import com.fjrcloud.utils.StatusUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by shengjian.lin on 17-1-18.
 */
@Controller
@RequestMapping("api/land/standard")
public class LandStandardController {

    @Autowired
    private LandStandardService service;

    @RequestMapping("save")
    @ResponseBody
    public ResponseBean save(LandStandard standard) throws BusinessException {

        return ResponseFactory.getResponseBean(StatusUtils.Success,service.save(standard));
    }
    @RequestMapping("get")
    @ResponseBody
    public ResponseBean get(Integer id){
        return ResponseFactory.getResponseBean(StatusUtils.Success,service.get(id));
    }
    @RequestMapping("del")
    @ResponseBody
    public ResponseBean del(Integer id){
        service.del(id);
        return ResponseFactory.getResponseBean(StatusUtils.Success);
    }
//    @RequestMapping("list")
//    @ResponseBody
//    public ResponseBean list(Integer pageNum, Integer pageSize){
//        return ResponseFactory.getResponseBean(StatusUtils.Success,service.list(pageNum,pageSize));
//    }
    @RequestMapping("clearing/list")
    @ResponseBody
    public ResponseBean listClearing(Integer pageNum, Integer pageSize){
        return ResponseFactory.getResponseBean(StatusUtils.Success,service.listClearing(pageNum,pageSize));
    }
    @RequestMapping("building/list")
    @ResponseBody
    public ResponseBean listBuilding(Formalities formalities,Integer pageNum, Integer pageSize){
        if (formalities == null){
            return ResponseFactory.getResponseBean(StatusUtils.Success,service.listBuilding(pageNum,pageSize));
        }else{
            return ResponseFactory.getResponseBean(StatusUtils.Success,service.listBuildingClass(formalities,pageNum,pageSize));
        }
    }
}
